package com.yuan.algorithms.base01;

import java.util.Scanner;

/**
 * @author YouYuan
 * <br>E-mail:1265161633@qq.com
 * <br>创建时间：2015年10月13日 上午11:20:26
 * <br>说明:
 */
public class 递归_二进制数中1的个数 {

	static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		while (in.hasNext()) {
			long n = in.nextLong();
			System.out.println(while_binSum(n));
			System.out.println(dg_binSum(n));
		}
	}
	private static int while_binSum(long n) {
		int sum = 0;
		while(n>0) {
			if ((n&1)==1) {
				++sum;
			}
			n >>= 1;
		}
		return sum;
	}
	
	private static int dg_binSum(long n) {
		if (n==0) {
			return 0;
		}
		if ((n&1)==1) {
			return dg_binSum(n>>1)+1;
		} else {
			return dg_binSum(n>>1);
		}
		
	}

}
